45] Phong shading: side effects, By Gregory Denby.
Imagine uses a routine called "phong shading" to produce a smooth appearance for its objects. To use a metaphor, it is as if a flexible plastic sheet is stretched from the centers of faces across the bounding vertices. As a result, the effects of shading are limited by the size of the faces.
It is easy to see how this works using a simple example. Create two "goblets" in the detail editor with the following cross section. The capital X is the first point, and it is placed on the axis. The x's are points along the line, placed at grid intersections and snapped to grid to insure a regular surface
x_x x_x
| | | |
| | x x
| | "view" | | "view"
| | | |
| | x |
X___x| | X__x_x| x
x___x x__x_x|
| |
| x
| |
| |
| |
x x
\x__x \x_x_x
x____|x x___x_|x
Perform Function/Mold/Sweep 36 sections on each cross-section.
Click the "A" on the Perspective window bar, rotate the view so that You can look into the goblets. Now Quickrender.
In the resulting image, notice the difference in shading on the surface marked "view" in the diagram. On the simpler goblet, the "view" surface does not appear flat but rounded like a bell. This is a direct result of the phong routine shading all the way around to the bottom edge. In the more detailed goblet, the shading is limited to the smaller areas defined.
Try other variations. Select the intermediate points on the more complex goblet and move them up or down towards the rim or bottom. Note how the resulting renders will have tighter or looser shading. Or, create a goblet whose cross section comes to a point at both the rim and base. Despite being knife sharp, phong shading inappropriately rounds these.
Further complications arise when specularity is added. The specular highlight makes a bright "hump" whose focus can be sharpened by increasing the hardness parameter. Use the goblets created above to inspect this.
Enter the attribute requestor for each goblet. Make both a 123, 123, 123 grey color. Make specularity also 123, 123, 123, and nudge the hardness up a bit to 24. In resulting renders, the highlights produced will also be either limited or spread out across the defined faces.
In many cases, one will need to balance the positive and negative results of phong shading and specularity, especially if objects will be used in animations. If objects are kept simple, with few areas of small facets, shading may be "pillowy," but highlights will spread more smoothly across them. The forms of other more detailed objects will be more accurate, but irregular glints and crinkles will appear if they have much specularity. Therefore, the overall appearance may be better when either the polygons are fewer, but the specularity is increased, or there are many tiny facets, but little specularity.
![owl-bar](Owl_bar.gif)
Pages made from the amigaguide version with the help of Mike's
RDAG2HTML
and the fabulous Dietmar's GoldED with the
WWW extension v2.